package com.wt.admin.service.ai.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wt.admin.domain.dto.ai.MCPDTO;
import com.wt.admin.domain.entity.ai.MCPEntity;
import com.wt.admin.domain.vo.ai.MCPVO;
import com.wt.admin.mapper.ai.MCPMapper;
import com.wt.admin.service.ai.MCPService;
import com.wt.admin.util.PageUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class MCPServiceImpl extends ServiceImpl<MCPMapper, MCPEntity> implements MCPService {

    @Resource
    private MCPMapper mcpMapper;

    @Override
    public PageUtil.PageVO<MCPVO> list(PageUtil.PageDTO<MCPDTO> data) {
        return PageUtil.findPage(data, page -> mcpMapper.list(page, data.getData()));
    }

    @Override
    public MCPVO edit(MCPDTO data) {
        saveOrUpdate(data);
        return BeanUtil.copyProperties(data,MCPVO.class);
    }

    @Override
    public MCPVO del(MCPDTO data) {
        removeById(data.getId());
        return null;
    }

    @Override
    public List<MCPVO> getMcpList() {
        return mcpMapper.getMcpList();
    }

    @Override
    public List<MCPEntity> findByIds(List<Integer> tools) {
        if(CollUtil.isEmpty(tools)) return new ArrayList<>();
        return mcpMapper.findByIds(tools);
    }
}
